<?php
   class Banner extends AppModel {
        var $alias  =   'Banner';
        var $name = 'Banner';
        var $useTable = 'banners';

        function paginateCount($conditions = null, $recursive = 0, $extra = array()) {
            $parameters = compact('conditions');
            $this->recursive = $recursive;
            $count = $this->find('count', array_merge($parameters, $extra));
            if (isset($extra['group'])) {
                $count = $this->getAffectedRows();
            }
            return $count;
        }
        function setCache() {
            $conditions = array(
                'Banner.published' => 1,
            );
            $cacheName = 'banner_list_all';
            $data = $this->find('all', array(
                        'fields' => 'Banner.title,Banner.url, Banner.banner_type,Banner.id, Banner.images, Banner.open_type,Banner.width,Banner.height',
                        'conditions' => $conditions,
                        'order' => array(
                            'Banner.id' => 'DESC'
                        )
            ));
            Cache::write($cacheName, $data, 'banners');
            return $data;
        }
        function writeBottomBanner() {

            $html = '<ul class="submenu">' . "\n";
            $this->writeCat(0, 0, $html);
            $html .= '</ul>';
            $resourse = fopen(CAKE_CORE_INCLUDE_PATH . DS . 'app' . DS . 'views' . DS . 'elements' . DS . 'catproductroot_menu.ctp', 'w');
            fwrite($resourse, $html);
        }
    }


?>
